import { h, defineComponent, toRefs } from '@vue/runtime-core';
import bulletImg from '../../assets/bunny-self.png'
import bunnyImagePath from "../../assets/bunny.png";
// import enemyPlaneImg from '../../assets/me.jpg'

export const SelfBulletInfo = {
  width: 61,
  height: 99,
  rotation: 0,
  dir: -1
}

export const EnemyBulltInfo = {
  width: 61,
  height: 99,
  rotation: 0,
  dir: 1
}

// 敌方飞机
export default defineComponent({
  props: ['x', 'y', 'rotation', 'dir', 'id'],
  setup(props, ctx) {
    // 解构会丢失引用，所以这里需要使用 toRefs
    // toRefs 和 reactive 的区别：
    const { x, y } = toRefs(props)

    return {
      x, y,
      rotation: props.rotation,
      dir: props.dir
    }
  },
  render(ctx) {
    return h("Sprite", 
    {
      x: ctx.x,
      y: ctx.y,
      rotation: ctx.rotation,
      texture: ctx.dir === 1 ? bunnyImagePath : bulletImg
    })
  }
})